<?
include ("config.php");
$conn=mysql_connect($host,$user,$password);
mysql_select_db($db);
mysql_query("SET NAMES UTF8");
$query="select * from vote_title";
$result=mysql_query($query);
if(mysql_num_rows(mysql_query("select * from vote_ip"))==0)
{
	echo "<script>alert('Not voted yet!');window.close();</script>";
	exit();  
}
?>
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<title>Questionnaire Survey System Management</title> 
<link href="main.css" rel="stylesheet" type="text/css" />
</head> 
<body>
<div id=voteresult>
<?php 
	while($row=mysql_fetch_assoc($result))
	{
?>
		<div class=title><?=$row["title"]?> Result:</div>
		<div class=votenr>
			<table width="900px" cellpadding="0px" cellspacing="0px" border="0px">
			<?
			$query2="select * from vote_choice where titleid=".$row["id"];
			$result2=mysql_query($query2);
			$query3="select sum(num) as num from vote_choice where titleid=".$row["id"];
			$result3=mysql_query($query3);
			if($row3=mysql_fetch_array($result3))
			{
				$nums=$row3["num"];
			}
			while ($row2=mysql_fetch_array($result2))
			{
			?>
				<tr><td class=vote_title><?=$row2["choice"];?></td>
				<td class=photo><img src="dot1.gif" width="<?=number_format((($row2["num"]/$nums)*100),2);?>%" height="15"></td>
				<td class=bfb><font color="#ff0000"><?=number_format((($row2["num"]/$nums)*100),2);?></font>%</td>
				<td class=ren><font color="#ff0000"><?=$row2["num"];?></font> people</td>
				</tr>
			<?
			}
			?>
			</table>
		</div>
		<div class=cytp>Voted by <font color="#CC0000"><?=$nums;?></font> people</div>  
<?php
	} 
?> 
</div>
<br />
<center>CopyRight@FengYl</center>
</body>
</html>
